import 'package:flutter/material.dart';
import '../main.dart';

class NavigatorDemo extends StatelessWidget {
  const NavigatorDemo({Key key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Container(
        child: Scaffold(
      appBar: AppBar(title: Text('demo page')),
      body: Center(
          child: ListView(
        children: [
          CellDemo('homeTT', action: () {
            Navigator.pushNamed(context, '/home');
          }),
          CellDemo('more', action: () {
            Navigator.pushNamed(context, '/about');
          }),
          CellDemo('form', action: () {
            Navigator.pushNamed(context, '/form');
          }),
          CellDemo('MaterialComponent', action: () {
            Navigator.pushNamed(context, '/mdc');
          }),
          CellDemo('Chip、DataTable、Card、Stepper', action: () {
            Navigator.pushNamed(context, '/chip');
          }),
          CellDemo('StateManager', action: () {
            Navigator.pushNamed(context, '/state');
          }),
          CellDemo('Stream', action: () {
            Navigator.pushNamed(context, '/stream');
          }),
          CellDemo('RxDart', action: () {
            Navigator.pushNamed(context, '/rxDart');
          }),
          CellDemo('BloC', action: () {
            Navigator.pushNamed(context, '/bloC');
          }),
          CellDemo('Http', action: () {
            Navigator.pushNamed(context, '/http');
          }),
          CellDemo('Animate', action: () {
            Navigator.pushNamed(context, '/animate');
          }),
          CellDemo('I18n', action: () {
            Navigator.pushNamed(context, '/i18n');
          }),
        ],
      )),
    ));
  }
}

class CellDemo extends StatelessWidget {
  final void Function() action;
  final String title;

  CellDemo(this.title, {this.action});

  @override
  Widget build(BuildContext context) {
    return Container(
      color: Colors.grey[200],
      width: double.infinity,
      child: FlatButton(
          onPressed: this.action,
          child: Text(
            this.title,
            style: TextStyle(fontSize: 16.0, color: Colors.black54),
          )),
    );
  }
}

class PageDemo extends StatelessWidget {
  final String title;
  PageDemo({this.title});

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text(title),
        elevation: 0.0,
      ),
      floatingActionButton: FloatingActionButton(
        child: Icon(Icons.arrow_back),
        onPressed: () {
          Navigator.pop(context);
        },
      ),
    );
  }
}
